#ifndef LISTS_H
#define LISTS_H

#include <stdio.h>

typedef enum MediaType_enum {
   MT_DVDISO,
   MT_MEDIALIST,
   MT_CDFLAC,
   MT_TRACKFLAC,
   MT_MAXTYPES,
} MediaType_t;

typedef struct MT_DVDISO_struct {
   char *file;
   char *author;
   char *title;
   char *cover;
} MT_DVDISO_t;

typedef struct MT_MediaList_struct {
   char *title;
   char *author;
   char *cover;
   char **dirlist;
} MT_MediaList_t;

typedef struct MT_CDFlac_struct {
   char *file;
   char *cue;
   char *title;
   char *author;
   char *cover;
} MT_CDFlac_t;

typedef struct MT_TrackFlac_struct {
   char *file;
   char *title;
   char *author;
   char *cover;
} MT_TrackFlac_t;

typedef union MediaElementU_union {
   MT_DVDISO_t *DVDISO;
   MT_MediaList_t *MediaList;
   MT_CDFlac_t *CDFlac;
   MT_TrackFlac_t *TrackFlac;
} MediaElementU_t;

typedef struct MediaElement_struct {
   MediaType_t Type;
   MediaElementU_t Element;
} MediaElement_t;

MT_DVDISO_t *NewDVDISOType(char *file,char *title, char *author, char *cover);
void SetDVDISOType(MT_DVDISO_t *node,char *file,char *title, char *author, char *cover);
void ClrDVDISOType(MT_DVDISO_t *node);
int WriteDVDISOType(FILE *fd, MT_DVDISO_t *node);

MT_MediaList_t *ReadMediaListType(FILE *fd);
void SetMediaListType(MT_MediaList_t *node, char *title, char *author, char *cover, char *dirs);
void ClrMediaListType(MT_MediaList_t *node);
int WriteMediaListType(FILE *fd, MT_MediaList_t *node);

MT_CDFlac_t *NewCDFlacType(char *file, char *cue, char *title, char *author, char *cover);
void SetCDFlacType(MT_CDFlac_t *node,char *file, char *cue, char *title, char *author, char *cover);
void ClrCDFlacType(MT_CDFlac_t *node);
int WriteCDFlacType(FILE *fd, MT_CDFlac_t *node);

MT_TrackFlac_t *NewTrackFlacType(char *file, char *title, char *author, char *cover);
void SetTrackFlacType(MT_TrackFlac_t *node,char *file, char *title, char *author, char *cover);
void ClrTrackFlacType(MT_TrackFlac_t *node);
int WriteTrackFlacType(FILE *fd, MT_TrackFlac_t *node);

MediaElement_t *ReadTXTNode(char *nodefile);
void ClrMediaElement(MediaElement_t *Element);
int WriteTXTNode(MediaElement_t *Element, char *nodefile);

#endif
